-
Notifications
You must be signed in to change notification settings - Fork 121
[REST API] Use case to generate and delete Application password #8400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REST API] Use case to generate and delete Application password #8400
Conversation
…ration and deletion network actions.
…password actions.
You can test the changes from this Pull Request by:
|
| /// | ||
| private var applicationPasswordName: String { | ||
| get async { | ||
| await UIDevice.current.model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the internal discussion [p1669977432588639/1669965496.085079-slack-C046HDZL87J], we should name the application in the following format: <bundle-id>.ios-app-client.<model-name>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d905e7a
| init(siteID: Int64, | ||
| networkcredentials: Credentials, | ||
| network: Network? = nil, | ||
| keychain: Keychain = Keychain(service: "com.automattic.woocommerce.applicationpassword")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the same service name for Keychain in the whole app: WooConstants.keychainServiceName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6b63664
| import Foundation | ||
| import Alamofire | ||
|
|
||
| public class ApplicationPasswordNetwork: Network { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining why this network is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b2f3d74
| } | ||
| } | ||
|
|
||
| @available(*, deprecated, message: "Not implemented. Use the `Result` based method instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use unavailable instead of deprecated since that fits this situation better.
| @available(*, deprecated, message: "Not implemented. Use the `Result` based method instead.") | |
| @available(*, unavailable, message: "Not implemented. Use the `Result` based method instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using unavailable will make the method unavailable, which makes ApplicationPasswordNetwork not satisfy the Network protocol requirements.
| @available(*, deprecated, message: "Not implemented. Use the `Result` based method instead.") | ||
| public func responseData(for request: URLRequestConvertible, completion: @escaping (Data?, Error?) -> Void) { } | ||
|
|
||
| @available(*, deprecated, message: "Not implemented. Use the `Result` based method instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the above comment:
| @available(*, deprecated, message: "Not implemented. Use the `Result` based method instead.") | |
| @available(*, unavailable, message: "Not implemented. Use the `Result` based method instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Empty<Swift.Result<Data, Error>, Never>().eraseToAnyPublisher() | ||
| } | ||
|
|
||
| @available(*, deprecated, message: "Not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the above comment:
| @available(*, deprecated, message: "Not implemented") | |
| @available(*, unavailable, message: "Not implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// - Returns: Generated `ApplicationPassword` instance | ||
| /// | ||
| func generateNewPassword() async throws -> ApplicationPassword { | ||
| let password = try await createApplicationPasswordUsingWPCOMAuthToken() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle deleting and generating the password again within this use case, or do you think it's better that it's handled from the outside? I just thought it would be more straightforward for the consumer of this use case to not have to call this method twice in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Started deleting the existing password when duplicate name error occurs - 38c7dec
itsmeichigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick updates! Everything looks good to me now 🚀
|
@itsmeichigo @selanthiraiyan merging #8418 here should solve the CI issue |
Add missing `networking_pods` dependencies to Yosemite in `Podfile`
Part of: #8394
Description
ApplicationPasswordUseCasethat works with WPCOM credentials.Testing instructions
Screenshots
NA
RELEASE-NOTES.txtif necessary.